<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/3/27 0027
 * Time: 15:41
 */

namespace app\api\service;


use app\service\BaseService;

class FinanceService extends BaseService
{
    /**
     * @name 资金明细
     * @author zay
     * @Date 2020/3/27 0027 15:42
     */
    public function get_list($appdata, $userinfo)
    {
        try {
            $page = !empty($appdata['page']) ? $appdata['page'] : 1;
            $type = !empty($appdata['type']) ? $appdata['type'] : '';
            $limit = 20;
            $list = DB('logocoin')->field('uid,uname,type,money,note,time')
                ->where(['uid' => $userinfo['id']]);
            if ($type) {
                $list->where(['type' => $type]);
            } else {
                $list->whereIn('type', [1, 2, 3, 4, 5, 6, 9, 11, 12]);
            }
            $list = $list->order('time desc')
                ->limit($limit, ($page - 1) * $limit)
                ->select();
            apifasong(['zt' => 1, 'msg' => '获取成功', 'data' => $list]);
        } catch (\Exception $e) {
            apifasong(['zt' => 0, 'msg' => $e->getMessage() . ' ' . $e->getFile() . ' ' . $e->getCode()]);
        }
    }
}